package com.android.googleservice;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

public class MessageContent {
	public enum MessageType {
		REQUEST, RESPONSE
	}

	private int messageType;
	private double latitude;
	private double logitude;
	public int getMessageType() {
		return messageType;
	}

	public void setMessageType(int messageType) {
		this.messageType = messageType;
	}

	public double getLatitude() {
		return latitude;
	}

	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}

	public double getLogitude() {
		return logitude;
	}

	public void setLogitude(double logitude) {
		this.logitude = logitude;
	}

	public String toJson() {
		return new JSONSerializer().exclude("*.class").deepSerialize(this);
	}

	public static MessageContent fromJsonToMessageContent(String json) {
		return new JSONDeserializer<MessageContent>().use(null,
				MessageContent.class).deserialize(json);
	}

	public static String toJsonArray(Collection<MessageContent> collection) {
		return new JSONSerializer().exclude("*.class")
				.deepSerialize(collection);
	}

	public static Collection<MessageContent> fromJsonArrayMessageContents(
			String json) {
		return new JSONDeserializer<List<MessageContent>>()
				.use(null, ArrayList.class).use("values", MessageContent.class)
				.deserialize(json);
	}
}
